Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split skb as soon http_parser returned TFW_PASS #1134

Merged
merged 3 commits into from
Dec 28, 2018
Merged

Conversation

vankoven
Copy link
Contributor

If ss_skb_split() fails, a part of the next http message will be added to the end of last parsed message. Forwarding such message will break response-request sequence. There is no sense to process the parsed message if split will fail: such message can't be forwarded and connection must be closed to recover.

Current master is also vulnerable for attack on response-request sequence attack:

  • cilent sends a pack of pipilined requests, but the first request in the pack has a Connection: close header
  • on current master Tempesta creates a subling message AND splits the skb only if Connection: close header is not set. So no split is performed.

If ss_skb_split() fails, a part of the next http message will be
added to the end of last parsed message. If the error happened,
there is no recourse, we must close the connection.
@vankoven vankoven force-pushed the ik-fix-msg-splitting branch from 4b1faed to b024333 Compare December 15, 2018 11:37
Copy link
Contributor

@aleksostapenko aleksostapenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, with minor comments corrections.

@@ -1894,40 +1894,17 @@ tfw_http_conn_send(TfwConn *conn, TfwMsg *msg)
* Siblings in HTTP are pipelined HTTP messages that share the same SKB.
*/
static TfwHttpMsg *
tfw_http_msg_create_sibling(TfwHttpMsg *hm, struct sk_buff **skb,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like function comment is outdated: @msg -> @hm.

/*
* The message is fully parsed, the rest of the data in the
* stream may represent another request or its part.
* If skb splitting has failed, the request cant be forwarded to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant -> can't. The same for tfw_http_resp_process().

@@ -3247,6 +3249,26 @@ tfw_http_resp_process(TfwConn *conn, const TfwFsmData *data)
goto bad_msg;
}

/*
* The message is fully parsed, the rest of the data in the
* stream may represent another request or its part.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request -> response

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch and good to merge the change after fix of the skb leak in tfw_http_req_process().

* process current one. But @skb must be freed then, since it's
* not owned by any message.
*/
if (!req_conn_close && skb) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If req_conn_close and skb != NULL (i.e. there are pipelined messages), then the skb leaks - nobody frees it.

@vankoven vankoven force-pushed the ik-fix-msg-splitting branch from 4f65bde to 72ba622 Compare December 27, 2018 23:24
Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge

@vankoven vankoven merged commit 5d91260 into master Dec 28, 2018
@vankoven vankoven deleted the ik-fix-msg-splitting branch December 28, 2018 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants